import React, { Component } from 'react'
import { connect } from 'dva';
import FormList from '../components/FormItem';
import { KEYS_EDIT } from '../enum';

interface Props {
  dispatch: Function;
  data: {
    id: string;
    users: Array<string>;
    name: string;
    state: string | number;
    setStateName: string;
  };
  match: {
    params: {
      id: string
    }
  };
  details: object;
}


@connect(({ task_month }) => ({
  data: task_month.editTaskDetails
}))
class Update extends Component<Props, any> {

  componentDidMount() {
    const { dispatch, match } = this.props;
    const { params } = match;

    dispatch({
      type: 'task_month/queryEditTaskById',
      payload: {
        id: params.id,
        keys: KEYS_EDIT
      }
    })
  }

  render() {

    return (
      <>
        <FormList data={this.props.data} key={Date.now()}/>
      </>
    );
  }
}

export default Update;